Skip to content

fix(transform): search transformed int dims continuously, repair in natural space#88

Merged
bartzbeielstein merged 1 commit into
mainfrom
fix/int-log10-dims
Jun 5, 2026
Merged

fix(transform): search transformed int dims continuously, repair in natural space#88
bartzbeielstein merged 1 commit into
mainfrom
fix/int-log10-dims

Conversation

@bartzbeielstein
Copy link
Copy Markdown
Contributor

Closes #87.

Problem

An integer dimension with an active transform was int-cast in transformed space: (10, 5000, "log10") became internal bounds (1, 3), so internal rounding collapsed the dimension to decade exponents in natural scale — and proposals drawn from the un-cast lower/upper float arrays (1.0, 3.699) could round to exponent 4, i.e. 10000, silently exceeding the declared cap of 5000 (observed in a live spotforecast2 tuning run on 2026-06-05). The sqrt analogue restricted int dims to perfect squares.

Fix

The integer constraint belongs to the natural scale, not the transformed scale:

  • transform_bounds keeps float internal bounds for int dims with an active transform (untransformed int and factor dims unchanged — pinned by a new companion test).
  • New SpotOptim.internal_var_type property; all internal-space repair sites (initial design, user X0, design top-up, acquisition candidates/fallbacks) use it, so transformed int dims are searched continuously.
  • New SpotOptim.repair_natural_X (+ utils.variables.repair_natural_X): rounds int dims in natural space and clips transformed ones to the declared bounds; applied in evaluate_function (the objective only ever sees admissible integers) and in the X_/best_x_ storage paths (serial, restart, steady-state parallel), so recorded history matches what the objective saw. Handles full- and reduced-dimension layouts.
  • SpotOptimProtocol extended; docs/spotoptim_class.qmd member list updated.

Tests

  • tests/test_int_log10_dims.py — 13 regression tests: continuous internal bounds, integer admissible values within [10, 5000] (never 10000), no decade collapse, bound respect in X_/best_x_ across serial and n_jobs=2, float+log10 unchanged, plain int dims unchanged, repair_natural_X unit behaviour.
  • test_transform_bounds_mixed_var_types updated — it asserted the buggy int-cast.

Verification

  • Full suite: 1743 passed (including slow tests, 13:54)
  • Fast suite (-m "not slow" -n auto): 1633 passed
  • ruff check src/ tests/ clean; black/isort applied to changed files
  • Both new docstring {python} examples execute

🤖 Generated with Claude Code

…atural space

Closes #87. An integer dimension with an active transform was int-cast in
TRANSFORMED space: (10, 5000, "log10") became internal bounds (1, 3), so
internal rounding collapsed the dimension to the decade exponents
{10, 100, 1000} in natural scale — and proposals drawn from the un-cast
lower/upper arrays (1.0, 3.699) could round to exponent 4, i.e. 10000,
silently EXCEEDING the declared cap (observed in a live spotforecast2
tuning run on 2026-06-05). The sqrt analogue restricted int dims to
perfect squares.

The integer constraint belongs to the natural scale, not the transformed
scale:

- transform_bounds keeps float internal bounds for int dims with an
  active transform (untransformed int and factor dims unchanged).
- New SpotOptim.internal_var_type property: per-dimension types for
  internal-space repair — "float" for transformed int dims. All
  internal-space repair sites (initial design, user X0, design top-up,
  acquisition candidates/fallbacks) now use it.
- New SpotOptim.repair_natural_X / utils.variables.repair_natural_X:
  rounds int dims to the nearest integer in NATURAL space and clips
  transformed ones to the declared bounds; applied in evaluate_function
  (the objective only ever sees admissible integers) and in the X_ /
  best_x_ storage paths (serial, restart, and steady-state parallel), so
  the recorded history matches what the objective saw. Handles full- and
  reduced-dimension layouts.
- SpotOptimProtocol extended with the new members.
- tests/test_int_log10_dims.py: 13 regression tests (continuous internal
  bounds, integer admissible values, no decade collapse, bound respect in
  history/best across serial and parallel paths, float+log10 and plain
  int dims unchanged). test_transform_bounds_mixed_var_types updated: it
  asserted the buggy int-cast; a new companion test pins the unchanged
  behaviour for untransformed int dims.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bartzbeielstein bartzbeielstein enabled auto-merge June 5, 2026 17:54
@bartzbeielstein bartzbeielstein merged commit f15d95f into main Jun 5, 2026
5 checks passed
@bartzbeielstein bartzbeielstein deleted the fix/int-log10-dims branch June 7, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

int + log10 dimensions collapse to decade exponents and can exceed the declared upper bound

1 participant